package com.eagle.demo.aspect;



import com.eagle.core.annotation.SelfAspect;
import com.eagle.core.aop.SelfAspectProxy;

import java.lang.reflect.Method;

/**
 * 自定义切面
 */
@SelfAspect(pkg = "com.eagle.demo.controller", cls = "DemoController")
//@SelfAspect(pkg = "com.eagle.demo.controller")
public class MyAspect extends SelfAspectProxy {

    private long begin;

    /**
     * 切入点判断
     */
    @Override
    public boolean intercept(Method method, Object[] params) throws Throwable {
//        return method.getName().equals("getUserList");
		return true;
    }

    @Override
    public void before(Method method, Object[] params) throws Throwable {
		System.out.println("---------- begin ----------");
        begin = System.currentTimeMillis();
    }

    @Override
    public void after(Method method, Object[] params) throws Throwable {
        System.out.println(System.currentTimeMillis() - begin);
        System.out.println("---------- end ----------");
    }
}
